# $Id: PKGBUILD 81027 2012-12-10 10:25:41Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jaroslaw Swierczynski <swiergot@aur.archlinux.org>
# Contributor: Eric Belanger <belanger@astro.umontreal.ca>
# Contributor: Bob Finch <w9ya@arrl.net>

pkgname=dosemu
pkgver=1.4.0
pkgrel=9
pkgdesc="DOS emulator"
arch=('i686' 'x86_64')
url="http://www.dosemu.org/"
license=('GPL' 'custom')
depends=('gpm' 'slang' 'sdl' 'libxxf86vm' 'libsndfile' 'sh' 'xorg-mkfontdir' 'xorg-bdftopcf' 'xorg-xlsfonts')
backup=('etc/dosemu/dosemu.conf'
	'etc/dosemu/dosemu.users'
	'etc/dosemu/global.conf')
install=dosemu.install
source=(http://downloads.sourceforge.net/sourceforge/dosemu/$pkgname-$pkgver.tgz
	http://downloads.sourceforge.net/sourceforge/dosemu/dosemu-freedos-1.0-bin.tgz
	kernel_version.patch
	fix-infinite-loop.patch
	cpu-support.patch)
md5sums=('0bba530637266f99d404ba15e3f118d4'
         '2e09774fe91cff4372cb4a393eb467f5'
         '15af2ca86b2e7d8835f0f837ea663c3d'
         'e8ea87d46c613130b26724facb5aa297'
         'ebb17406a7d302f6c4ad2b67304f31b6')

build() {
  cd $srcdir/$pkgname-$pkgver

  patch -Np1 -i ${srcdir}/kernel_version.patch
  patch -Np1 -i ${srcdir}/fix-infinite-loop.patch
  patch -Np1 -i ${srcdir}/cpu-support.patch
  sed -i 's|extern int yyget_leng|extern size_t yyget_leng|' src/base/init/lexer.h

  unset CFLAGS
  ./configure --prefix=/usr --with-fdtarball=$srcdir/dosemu-freedos-1.0-bin.tgz --mandir=/usr/share/man
  make
}

package(){
  cd $srcdir/$pkgname-$pkgver

  make DESTDIR=$pkgdir install

  ln -s /usr/share/dosemu/drive_z $pkgdir/etc/dosemu/drives/z
  install -dm0755 $pkgdir/etc/sysctl.d
  echo "vm.mmap_min_addr = 0" >$pkgdir/etc/sysctl.d/dosemu.conf

  install -D -m 644 COPYING $pkgdir/usr/share/licenses/$pkgname/COPYING
  install -D -m 644 COPYING.DOSEMU $pkgdir/usr/share/licenses/$pkgname/COPYING.DOSEMU
}
